package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
//        FileInputStream fis=new FileInputStream("note.txt");
//        File file=new File("note.txt");
        File file=new File("note.txt");
        FileInputStream fis=new FileInputStream(file);
        byte [] data=new byte[(int)file.length()];
        fis.read(data);
        String str=new String(data, StandardCharsets.UTF_8);//String提供的构造器可以将字节数组所有内容按照指定的字符集转换为字符串
        System.out.println(str);
        fis.close();

    }
}
